class Organ < Searchable
              
  set_table_name 'orgao'

  belongs_to :organtype, :foreign_key => "tipoorgao"
  belongs_to :organ, :foreign_key => "pai"
  belongs_to :campu, :foreign_key => "campus"

  has_many :disciplina
  has_many :option
  has_many :place

  validates_presence_of :id
  validates_presence_of :sigla

  def to_s
    self.nome
  end


  def sigla_pai
    Organ.find_by_id(self.pai).sigla + "-" + self.sigla
  end

  def nome_pai
    Organ.find_by_id(self.pai).nome
  end

  def nome_campus
    Campu.find_by_id(self.campus).sigla
  end
end
